const express = require('express');
const router = express.Router();
const data = [];
for(let i = 1; i < 51; i++)
    data.push({
        id: `${i}`,
        code: `code${i}`,
        name: `name${i}`
    });

router.get('/', (req, res) => {
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});
router.get('/forSaleProformaInvoice', (req, res) => {
    const content = [];
    for(let i = 0; i < 20; i++)
        content.push({
            id: `2020${i}`,
            lV1Code: `lV1Code${i}`,
            lV2Code: `lV2Code${i}`,
            lV2Name: `lV2Name${i}`,
            lV3Code: `lV3Code${i}`,
            lV3Name: `lV3Name${i}`,
            lV4Code: `lV4Code${i}`,
            lV4Name: `lV4Name${i}`,
            lV5Code: `lV5Code${i}`,
            lV5Name: `lV5Name${i}`,
            unitVolume: 34124,
            colorCode: 'dadsa',
            color: 'yellow'
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 20,
        }
    });
});
router.get('/topLevel', (req, res) => {
    const content = [];
    for(let i = 0; i < 10; i++) content.push({
        id: `id${i}`,
        code: `513200${i}`,
        name: `name${i}`,
        remark: `remark${i}`,
        type: 2,
        isLeaf: true,
        rowVersion: 'rowVersion',
        options: ['update', 'abandon']
    });

    res.json({
        message: 'ok',
        payload: {
            content,
            totalElements: 10,
        }
    });
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.get('/:id/children', (req, res) => {
    const content = [];
    for(let i = 0; i < 10; i++) content.push({
        id: `id${i}`,
        code: `513200${i}`,
        name: `name${i}`,
        remark: `remark${i}`,
        type: 2,
        isLeaf: true,
        rowVersion: 'rowVersion',
        options: ['update', 'abandon']
    });

    res.json({
        message: 'ok',
        payload: {
            content,
            totalElements: 10,
        }
    });
});
module.exports = router;
